﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.MovieRecorder.CUiMRCRecorderCommand
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using COMMANDPARAMSLib;
using System;
using System.IO;
using System.Windows;
using Tecnomatix.Engineering;
using Tecnomatix.Engineering.Ui;


namespace DnProcessSimulateCommands.MovieRecorder;

public class CUiMRCRecorderCommand : TxButtonCommand
{
  private CApMRCMovieRecorderEnabler m_enabler;

  public CUiMRCRecorderCommand() => this.m_enabler = new CApMRCMovieRecorderEnabler();

  public virtual string Category => MRCStringTable.MOVIE_RECORDER_COMMAND_CATEGORY;

  public virtual void Execute(object cmdParams)
  {
    this.m_enabler.IsRunning = true;
    CUiMRCRecorderWindow mrcRecorderWindow = cmdParams == null ? new CUiMRCRecorderWindow() : new CUiMRCRecorderWindow(this.ParseParams(cmdParams), SettingsView.FileAttach);
    ((Window) mrcRecorderWindow).Closed += new EventHandler(this.recorderWindow_Closed);
    ((Window) mrcRecorderWindow).Show();
    ((UIElement) mrcRecorderWindow).InvalidateVisual();
  }

  private CApMRCRecorderSettings ParseParams(object cmdParams)
  {
    string fileName;
    ((ICoRecorderParams) (cmdParams as CoRecorderParams)).GetFileName(ref fileName);
    FileInfo fileInfo = new FileInfo(fileName);
    return new CApMRCRecorderSettings()
    {
      FileName = Path.GetFileNameWithoutExtension(fileInfo.Name),
      FileDestination = fileInfo.DirectoryName
    };
  }

  private void recorderWindow_Closed(object sender, EventArgs e)
  {
    this.m_enabler.IsRunning = false;
  }

  public virtual string Name => MRCStringTable.MOVIE_RECORDER_COMMAND_NAME;

  public virtual ITxImage Image => (ITxImage) TxImageManager.GetImageByKey("MovieRecorder");

  public virtual ITxCommandEnabler CommandEnabler => (ITxCommandEnabler) this.m_enabler;

  public virtual string Description => MRCStringTable.MOVIE_RECORDER_DESCRIPTION;
}
